package org.demo.patten.iterator;


import java.util.ArrayList;
import java.util.List;

/**
 * @author zhuj
 * @date 2025/3/29
 * @apiNote
 */
public class BookShelf implements Aggregate<Book> {
    private final List<Book> books = new ArrayList<>();
    public void addBook(Book book) {
        books.add(book);
    }
    public Book getBookAt(int index) {
        return books.get(index);
    }
    public int getLength() {
        return books.size();
    }
    @Override
    public Iterator<Book> createIterator() {
        return new BookShelfIterator(this);
    }
}
